const merge = require('webpack-merge')
const tsImportPluginFactory = require('ts-import-plugin')

module.exports = {
  publicPath: '/',
  lintOnSave: true,
  devServer: {
    host: '0.0.0.0',
    port: 9960,
    open: true,
    disableHostCheck: true,
    proxy: {
        '/pi-cz': {
            target: 'https://test-czsmb.zrwbjj.com',
            changeOrigin: true,
            secure:true,
            ws: true,
            pathRewrite: {
            '^/pi-cz': '/pi-cz'
            } 
        }
    }
  },
  chainWebpack: config => {
    config.module
        .rule('ts')
        .use('ts-loader')
        .tap(options => {
            options = merge(options, {
                happyPackMode: true,
                transpileOnly: true,
                getCustomTransformers: () => ({
                    before: [
                        tsImportPluginFactory({
                            libraryName: 'vant',
                            libraryDirectory: 'es',
                            // 这句必须加上，不然修改主题没有效果
                            style: name => `${name}/style/less`
                        })
                    ]
                }),
                compilerOptions: {
                    module: 'es2015'
                }
            })
            return options
        })
  },
  // 生产环境是否生成 sourceMap 文件
  productionSourceMap: false
}